<? 
#while (list($name, $array) = each($this->bookmarks)):   
#    $first = $array;
#    break; 
#endwhile;
#reset($this->bookmarks); 


#if (isset($this->groupname)) {
#    while (list($name, $array) = each($this->bookmarks)): 
#        if ($name==$this->groupname) {
#            $first = $array;
#            break;
#        }
#    endwhile;
#}
#reset($this->bookmarks); 

$names    = array_keys($this->bookmarks);
$first    = $this->items;
$index    =  rand ( 0 , sizeof($first) - 1 );

$onsearch = "location.href='/favorites/list/param/' + this.value";
$onchange = "location.href='/favorites/sort/group/' + this.value";
$title    = array (
              'href'=>$this->url(array( 
                                    "controller" => "request", 
                                    "action"     => "pagegroup", 
                                    "groupname"  => $this->groupname, 
                                    "pagenumber" => 1)), 
              'text'=>$this->groupname
                   );
$subject  = html_entity_decode( $first[$index]->Name );
$dot      = array();
$items    = array();
foreach ($names as $name) {
    $dot[]   = array (
                      "href"     => $this->url(array('action'=>'sort','group'=>$name)),
                      "selected" => $name==$this->groupname
                      );
    $items[] = array (
                      "text"     => $name,
                      "selected" => $name==$this->groupname
                      ); 
}

 

$v    = $index + 1;
$url  = "/request/picture/name/{$first[$index]->Group}/index/{$first[$index]->Id}";
$url2 = "/request/icon/group/{$first[$index]->Group}/slide/{$first[$index]->Id},{$first[$v]->Id}";
  
?> 

 <table><tr><td cellspacing="0" cellpadding="0">
  
<?= $this->partial ('viewport.phtml', array(
                                              'onsearch'  => $onsearch,
                                              'onchange'  => $onchange,
                                              'title'     => $title,
                                              'subject'   => $subject,
                                              'dots'      => $dot,
                                              'url'       => $url2,
                                              'items'     => $items 
                                             )); ?>


 <?
    foreach($this->bookmarks[$this->groupname] as $bookmark) {
   $js[] = '{ id:"' . $bookmark->Id . '", subject:"' . str_replace('"', '', $bookmark->Name) . '" }';
        
    }
?>

<? foreach($first as $bookmark):
 
    $request = $this->url(array ("controller" => "request",
                                   "action"     => "async",
                                   "group"      => $bookmark->Group,
                                   "key"        => $bookmark->Id,
                                   "show"       => 1
                                   ) );  

    $target  = $this->url(array ("controller" =>"favorites",
                                   "action"     =>"browse",
                                   "page"       =>$this->page,
                                   "group"      =>$bookmark->Group,
                                   "key"        =>$bookmark->Id,
                                   "item"       =>$bookmark->Id,
                                   "show"       =>1
                                   ) );  


 ?>

 <div class='home'  style="background:url(/request/picture/name/<?= $bookmark->Group ?>/index/<?= $bookmark->Id ?>/thumb/256);background-size:248px;"> 

   <table cellspacing='0' cellpadding='4' class="filler">
     <tr>
       <td align="center" valign="bottom">              
          <a href="javascript:void(0)" onclick="AsyncRequest('<?= $Request ?>', '<?= $Target ?>')">               
             <!-- <img src="/request/group/name/<?= $group->Name ?>/size/144"
               onerror="this.src='/images/file-broken.png'"/> -->
           </a>  
       </td>
     </tr>
    <tr>
      <td valign="bottom"> 

 <div align='left' style="color:#F6E4CC" class="shadow-black" id="db<?= $bookmark->Id ?>">
<a href="javascript:void(0)" onclick="AsyncRequest('<?= $request ?>', '<?= $target ?>', 'db<?= $bookmark->Id ?>')">Browse <?= $bookmark->Count ?> articles</a> | 
<a href='<?= $this->url(array('action'=>'bookmark','group'=>$bookmark->Group,'key'=>$bookmark->Path)) ?>'
  onclick="if(!confirm('Are you sure you want to delete this bookmark?'))return false;" >Delete</a>
  <br/> 
<?= deSubject(html_entity_decode($bookmark->Name)) ?> </div> 


</td>
    </tr>
   </table> 

  
 </div> 

<? endforeach ?>



</td></tr></table>

<center>
        <?  $p = new Default_Model_Paginator;
            $p->PageSize = 10;
             echo $p->Pages($this->size, $this->page, "/favorites/home/group/{$this->groupname}/page/"); ?>


</center>

<script language="javascript">
LoadCarousel ("<?= $this->groupname ?>", [<?= implode (',', $js) ?>]);
</script>













